package com.example.lianxirenlist;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class ListXiang extends AppCompatActivity {
ListShuJuKu helder;
private static  final String TAG="taf";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_xiang);
        iniview();
    }
    private void iniview(){
        helder = new ListShuJuKu(this, "Persion", null, 1);
        Button b=findViewById(R.id.butt_edit);
        Button button1=findViewById(R.id.butt_shan);
        TextView textView=findViewById(R.id.text_user_phone);
        TextView textView1=findViewById(R.id.text_user_phone1);
        TextView textView2=findViewById(R.id.text_user_phone2);
        Intent intent=getIntent();
       String id= intent.getStringExtra("id");
        String s=helder.selectUser(id);
      textView.setText(s);
       DataBean d=helder.selectphone(id);
        String call=d.getPhone();
       textView1.setText(call);
          textView2.setText(d.getTel());

        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(ListXiang.this,Edit.class);
                intent.putExtra("name",s);
                intent.putExtra("call",call);
                intent.putExtra("tel",d.getTel());
                intent.putExtra("id",id);
                startActivity(intent);
            }
        });
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                helder.deletephone(id);
                helder.deleteuser(id);
                Intent intent1=new Intent(ListXiang.this,MainActivity.class);
                startActivity(intent1);
            }
        });
    }
}